#include "comm.h"

//写入数据 A

int main()
{
    int pipefd = open(IPC_FIFO, O_WRONLY);
    if (pipefd < 0)
    {
        cout << "open err" << endl;
        exit(-1);
    }

#define SIZE 1024
    char line[SIZE];
    printf("请输入你的消息# ");
    // const char *msg = "i am process A";
    fflush(stdout);
    memset(line, 0, sizeof(line));
    if (fgets(line, sizeof(line), stdin) != nullptr)
    {
        // abcd\n\0
        line[strlen(line) - 1] = '\0';
        write(pipefd, line, strlen(line));
    }
    else
    {
        cout<<"write err"<<endl;
    }
    return 0;
}